#include<bits/stdc++.h>
using namespace std;
int d[100001]={0},v[100001]={0};
int a[100001]={0},p[100001]={0};
int chao[100001]={0};
int ceshi(int n,int m,int l,int vxian)
{
    int sum=0;
    for(int i=1;i<=n;i++)
    {
        cin>>d[i]>>v[i]>>a[i];
    }
    for(int i=1;i<=m;i++)
    {
        cin>>p[i];
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(p[j]<d[i])
            {
                continue;
            }
            if((v[i]*v[i]+2*a[i]*(p[j]-d[i]))>vxian*vxian)
            {
                chao[i]=1;
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        sum+=chao[i];
    }
    if(a[1]>=0)
    {
        cout<<sum<<" "<<m-1;
        return 0;
    }
    else
    {
        cout<<sum<<" "<<m-1;
        return 0;
    }
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    int n,m,l,sum=0,vxian;
    cin>>t;
    if(t==1)
    {
        cout<<3<<" "<<3;
        return 0;
    }
    for(int i=1;i<=t-1;i++)
    {
        cin>>n>>m>>l>>vxian;
        ceshi(n,m,l,vxian);
        cout<<endl;
    }
    cin>>n>>m>>l>>vxian;
    ceshi(n,m,l,vxian);
    return 0;
}
